class Course(db.Model):
    __tablename__ = "course"

    course_id = db.Column(db.Integer, primary_key=True, unique=True)
    course_name = db.Column(db.String(8))
    department = db.Column(db.String(8))
    description = db.Column(db.Text)
    credit = db.Column(db.Float)
    price = db.Column(db.Float)
    # 用来标记学期，用5位数字表示，如20191表示2019年第一学期，一年只有两个学期
    # 这里是按照时间分配学期，例如，现在是2020年5月，记录为2020第一学期，并非传统的2019-2020第二学期
    taught = db.relationship("Teaches", backref="course")
    taken = db.relationship("Takes", backref="course")
    section = db.relationship("Section", backref="course")
    bill = db.relationship("Bill", backref="course")

    # pre_course = db.relationship("Prerequisite",backref="pre_course")
    # course = db.relationship("Prerequisite",backref="course")

    def __init__(self, **kwargs):
        super(Course, self).__init__(**kwargs)
        self.price = 100 * self.credit